package com.ruoyi.project.beautyflower.bankCard.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.beautyflower.bankCard.domain.BankCard;
import com.ruoyi.project.beautyflower.bankCard.service.IBankCardService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 银行管理 信息操作处理
 * 
 * @author lxs
 * @date 2018-10-16
 */
@Controller
@RequestMapping("/beautyflower/bankCard")
public class BankCardController extends BaseController
{
    private String prefix = "beautyflower/bankCard";
	
	@Autowired
	private IBankCardService bankCardService;
	
	@RequiresPermissions("beautyflower:bankCard:view")
	@GetMapping()
	public String bankCard()
	{
	    return prefix + "/bankCard";
	}
	
	/**
	 * 查询银行管理列表
	 */
	@RequiresPermissions("beautyflower:bankCard:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BankCard bankCard)
	{
		startPage();
        List<BankCard> list = bankCardService.selectBankCardList(bankCard);
		return getDataTable(list);
	}
	
	/**
	 * 新增银行管理
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存银行管理
	 */
	@RequiresPermissions("beautyflower:bankCard:add")
	@Log(title = "银行管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BankCard bankCard)
	{		
		return toAjax(bankCardService.insertBankCard(bankCard));
	}

	/**
	 * 修改银行管理
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		BankCard bankCard = bankCardService.selectBankCardById(id);
		mmap.put("bankCard", bankCard);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存银行管理
	 */
	@RequiresPermissions("beautyflower:bankCard:edit")
	@Log(title = "银行管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BankCard bankCard)
	{		
		return toAjax(bankCardService.updateBankCard(bankCard));
	}
	
	/**
	 * 删除银行管理
	 */
	@RequiresPermissions("beautyflower:bankCard:remove")
	@Log(title = "银行管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(bankCardService.deleteBankCardByIds(ids));
	}
	
}
